package com.ruoyi.web.controller.biz;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.biz.domain.BizParcelPic;
import com.ruoyi.biz.service.IBizParcelPicService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 邮包图片Controller
 * 
 * @author ruoyi
 * @date 2022-01-10
 */
@RestController
@RequestMapping("/biz/pic")
public class BizParcelPicController extends BaseController
{
    @Autowired
    private IBizParcelPicService bizParcelPicService;

    /**
     * 查询邮包图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:pic:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizParcelPic bizParcelPic)
    {
        startPage();
        List<BizParcelPic> list = bizParcelPicService.selectBizParcelPicList(bizParcelPic);
        return getDataTable(list);
    }

    /**
     * 导出邮包图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:pic:export')")
    @Log(title = "邮包图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizParcelPic bizParcelPic)
    {
        List<BizParcelPic> list = bizParcelPicService.selectBizParcelPicList(bizParcelPic);
        ExcelUtil<BizParcelPic> util = new ExcelUtil<BizParcelPic>(BizParcelPic.class);
        util.exportExcel(response, list, "邮包图片数据");
    }

    /**
     * 获取邮包图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:pic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizParcelPicService.selectBizParcelPicById(id));
    }

    /**
     * 新增邮包图片
     */
    @Log(title = "邮包图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(BizParcelPic bizParcelPic)
    {
        return toAjax(bizParcelPicService.insertBizParcelPic(bizParcelPic));
    }

    /**
     * 修改邮包图片
     */
    @PreAuthorize("@ss.hasPermi('system:pic:edit')")
    @Log(title = "邮包图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizParcelPic bizParcelPic)
    {
        return toAjax(bizParcelPicService.updateBizParcelPic(bizParcelPic));
    }

    /**
     * 删除邮包图片
     */
    @PreAuthorize("@ss.hasPermi('system:pic:remove')")
    @Log(title = "邮包图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizParcelPicService.deleteBizParcelPicByIds(ids));
    }
}
